<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jsonp01</title>
    <script>
        function loadData1(){
            let xhr=new XMLHttpRequest();
            xhr.open("get","http://127.0.0.1/ajax/service/selectProductById.php?id=1");
            xhr.onload=function(){
                if(xhr.status){
                    console.log(xhr.responseText);
                }
            }
            xhr.send();
        }

        function loadData(){
            let scriptTag = document.createElement("script");
            scriptTag.src="http://127.0.0.1/ajax/service/selectProductById_Jsonp.php?methodName=showInfo&id=1";
            document.querySelector("head").appendChild(scriptTag);
            console.log(scriptTag);
            scriptTag.remove();
        }
        function showInfo(data){
            console.log(data)
            document.querySelector("#show").innerText = JSON.stringify(data);
        }





    </script>
</head>
<body>
    <input type="button" value="loadData" onclick="loadData()" />
    <input type="button" value="btn" onclick="console.log(new Date());">
    <hr>
    <div id="show" >

    </div>
</body>
</html>